<template>
    <div>
        <h5>vuex-子组件2</h5>
        <p>vuex的数据展示</p>
        <!-- <p>{{ $store.state }}</p> -->
        <p>{{ $store.state.msg }} => <input v-model="$store.state.msg" type="text" /> </p>
        <p>{{ $store.state.num }} => <input v-model="num" type="text" /> </p>
        <p>{{ $store.state.arr }} => <input type="button" value="异步数据加载（计时器模拟）" @click="$store.dispatch('initArr',{name:'vuexChildTwo'})">  </p>
        <p>{{ $store.state.user }}</p>
    </div>
</template>

<script setup>
import { computed } from 'vue';
import { useStore } from 'vuex';
let $store = useStore();

let num = computed({
    get() {
        return $store.state.num;
    },
    set(nv) {
        $store.commit("setNum", nv)
    }
})
</script>

<style lang="scss" scoped>

</style>